import Mock from "mockjs";
import {param2Obj} from '@/utils/paramsUrl'

// 保存mock数据
var list = []
for(var i=0;i<400;i++){
    var obj={
        id:Mock.mock('@guid'),
        order: Mock.mock('@id'),
        name: Mock.mock('@cname'),
        phone: Mock.mock({phone:/^[1]([3-9])[0-9]{9}$/}),
        coursename: "幼儿英语入门课程",
        money: Mock.mock('@integer(10000, 30000)'),
        type: Mock.mock('@integer(0, 4)'), //0待支付 1已关闭 2待确定 3学习中 4已完成
        date: Mock.mock('@datetime'),
    }

    list.push(obj)
}


export default {
    getData:config=>{
        const {page,pagesize} = param2Obj(config.url)
        console.log(page,pagesize)
        var newArr = list.filter((item,index)=>{
            return (page-1)*pagesize <= index && index < page * pagesize
        })
        return{
            code:200,
            msg:'获取数据成功',
            data:newArr,
            total:list.length
        }
    }
}